package io.adrainty.bolee.framework.commons.exception;

import io.adrainty.bolee.framework.commons.basic.ResponseCode;
import lombok.Getter;

import java.io.Serial;

/**
 * @author adrainty
 * @version v1.0.0
 * @since 2025/6/12 下午2:00
 */

@Getter
@SuppressWarnings("unused")
public class AppException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = -2247548998844722224L;

    private final int code;

    private final String message;

    public AppException(String message) {
        super(message);
        this.code = 500;
        this.message = message;
    }

    public AppException(int code, String message) {
        super(message);
        this.code = code;
        this.message = message;
    }

    public AppException(ResponseCode responseCode) {
        super(responseCode.getDesc());
        this.code = Integer.parseInt(responseCode.getCode());
        this.message = responseCode.getDesc();
    }

    public AppException(ResponseCode responseCode, String msg) {
        super(msg);
        this.code = Integer.parseInt(responseCode.getCode());
        this.message = msg;
    }

}
